{capture name="select_box_field_distance"}
	{assign var=radiusArr value=','|explode:'0,10,20,30,40,50'}
	<select class="searchGeoDistance" name="{$id}[location][radius]" {$parameters} >
		{foreach from=$radiusArr item=radius}
			{if $radius == 0}
				<option value="">[[Within $radius {$GLOBALS.radius_search_unit}]]</option>
			{else}
				<option value="{$radius}" {if $value.location.radius == $radius}selected="selected"{/if} >[[Within $radius {$GLOBALS.radius_search_unit}]]</option>
			{/if}
		{/foreach}
	</select>
{/capture}
{assign var="select_box_field_distance" value="`$smarty.capture.select_box_field_distance`"}

<input type="text"  id="{$id}" name="{$id}[location][value]" value="{$value.location.value}" />
{if  $enable_search_by_radius}
	{if $searchWithin}
		<div style="padding-top:5px;">{$select_box_field_distance}</div>
	{else}
		<input type="hidden"  name="{$id}[location][radius]" value="10" />
	{/if}
{/if}
{literal}
<style type="text/css">
.location {
	color: #989898;
}
</style>
<script>
$(function() {
	if ($("#{/literal}{$id}{literal}").val() == '') {
		$("#{/literal}{$id}{literal}").val('{/literal}[[City, State or Zip Code]]{literal}');
		$("#{/literal}{$id}{literal}").addClass('location');
	}
	$("#{/literal}{$id}{literal}").focus(function(){
		if ($("#{/literal}{$id}{literal}").val()=='{/literal}[[City, State or Zip Code]]{literal}')
			$("#{/literal}{$id}{literal}").val('');
	});

	$("#{/literal}{$id}{literal}").blur(function(){
		$("#{/literal}{$id}{literal}").removeClass('location');
		if ($("#{/literal}{$id}{literal}").val()=='') {
			$("#{/literal}{$id}{literal}").val('{/literal}[[City, State or Zip Code]]{literal}');
			$("#{/literal}{$id}{literal}").addClass('location');
		}
	});

	$("#search_form").submit(function(){
		if ($("#Location").val()=='{/literal}[[City, State or Zip Code]]{literal}')
			$("#Location").val('');
	});

	$("#quickSearch").submit(function(){
		if ($("#Location").val()=='{/literal}[[City, State or Zip Code]]{literal}')
			$("#Location").val('');
	});

	$("#quickSearchForm").submit(function(){
		if ($("#Location").val()=='{/literal}[[City, State or Zip Code]]{literal}')
			$("#Location").val('');
	});
});
</script>
{/literal}
{* BEGIN AUTOCOMPLETE *}
{if $form_fields.$id.use_autocomplete == 1 || $theField.use_autocomplete == 1}
	{assign var="parentID" value=false}
	{include file='../field_types/search/autocomplete.tpl'}
{/if}
{* END AUTOCOMPLETE *}
